/*
 * FireComparisor.cpp
 *
 *  Created on: Sep 1, 2013
 *      Author: Jeff
 */

#include "FileComparisor.h"
#include "exception.h"

namespace fs {

bool FileComparisor::readJsonFromFile(const char* file, Json::Value* json)
{
	std::fstream json_stream;
	json_stream.open(file, std::ios::in);

	Json::Reader reader;
	return reader.parse(json_stream, *json, false);
}

void FileComparisor::init_right_input(std::string right){
	std::ifstream file(right.c_str());
	if(!file.good())
	{
		FileNotFoundException e(right);
		throw e;
	}

	rightFileReader = new FileReader(right.c_str());
}

int FileComparisor::read_right(char * buffer, int length){
	return rightFileReader->read(buffer, length);
}

void FileComparisor::close_right_input(){
	delete rightFileReader;
}

/*void FileComparisor::init_left_input(std::string left){
	Json::Value json;
	readJsonFromFile(left.c_str(), &json);
	leftFileReader = new FileReader(json);
}
int FileComparisor::read_left(char * buffer, int length){
	return leftFileReader->read(buffer, length);
}

void FileComparisor::close_left_input(){
	delete leftFileReader;
}*/

} /* namespace fs */
